package com.yanqu.road.entity.decoration;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.HashMap;
import java.util.Map;

@FieldTypeAnnotation(tableName = "t_u_mammon_offline_add", desc = "离线获取的财神成就")
public class UserMammonOfflineAdd extends DataObject {

    @FieldTypeAnnotation(desc = "玩家id", update = true, select = true)
    private long userId;

    @FieldTypeAnnotation(desc = "财神明细")
    private Map<Integer, Integer> countMap = new HashMap<>();

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public Map<Integer, Integer> getCountMap() {
        return countMap;
    }

    public void setCountMap(Map<Integer, Integer> countMap) {
        this.countMap = countMap;
        setUpdateOption();
    }

    public void addCount(int type, int val){
        int old = countMap.getOrDefault(type, 0);
        countMap.put(type, val + old);
        setUpdateOption();
    }
}
